<?php echo $sidebar; ?>
<?php echo generate_banners(); ?>
<?php
$leilao_opened = '';
$leilao_closed = '';
$leilao_maxlive = '';
?>

<div class="col-md-9 col-xs-9 home-container-list">
    <div class="box-header-btn-leilao">
        <a href="<?php echo site_url('/'); ?>" class="next-leiloes">Próximos Leilões</a> 
        <a href="<?php echo site_url('ultimos-realizados.html'); ?>" class="last-leiloes">últimos realizados</a>
    </div>

    <ul class="box-list-leilao">
        <?php
        if ($data_leiloes) :
            foreach ($data_leiloes as $row) :
                $image = render_image_leilao($row);
                if ($row->STATUS == 1 || $row->STATUS == 2):
                    $leilao_opened .= '<li><a href="' . site_url('lotes-leilao/' . $row->ID) . '">' . $row->TITLE . '<span class="media-num-lotes">' . $row->NUM_LOTES . '</span></a></li>';
                    $leilao_maxlive .= '<li><a href="' . site_url('maxlive-' . $row->ID . '.html') . '">'
                            . $image
                            . $row->TITLE . '</a></li>';
                endif;
                if ($row->STATUS == 3):
                    $leilao_opened .= '<li><a href="#nolote">' . $row->TITLE . '<span class="media-num-lotes">' . $row->NUM_LOTES . '</span></a></li>';
                endif;
                if ($row->STATUS == 4):

                    $leilao_closed .= '<li><a href="' . site_url('lotes-leilao/' . $row->ID) . '">' . $row->TITLE . ' | <small>' . extract_data($row->DATA, '/') . '</small></a></li>';
                endif;
                ?>
                <li class="leilao-item"><a
                        href="<?php echo $row->STATUS == 1 || $row->STATUS == 2 || $row->STATUS == 4 ? site_url('lotes-leilao/' . $row->ID) : 'javascript:void(0);'; ?>">
                        <div class="data-info">
                            <strong class="data-info-date">
                                <?php
                                if (empty($row->LABEL)) :
                                    echo extract_data($row->DATA, '/');
                                else :
                                    echo $row->LABEL;


                                endif;
                                ?>
                            </strong>
                            <strong class="data-info-hour">
                                <?php echo substr(extract_time($row->DATA), 0, 2); ?>H
                            </strong>
                            <div class="clearfix"></div>
                        </div>
                        <div class="position-img">
                            <?php
                            echo $image;
                            ?>


                        </div>
                        <div class="clearfix"></div>
                        <h3 class="title-leilao"><?php echo substr($row->TITLE, 0, 30); ?></h3>
                        <div class="info-home-leilao">
                            <?php echo $row->DESCRICAO; ?>

                        </div>


                        <?php
                        $cod = $row->STATUS;
                        $class_status = '';
                        $text_status = '';
                        switch ($cod) :
                            case 1 :
                                $class_status = ' lance';
                                $text_status = 'ABERTO PARA LANCES';

                                // $class_status = ' andamento';
                                // $text_status = 'TEMPO REAL';
                                break;
                            case 2 :
                                $class_status = ' lance';
                                $text_status = 'ABERTO PARA LANCES';

                                break;
                            case 3 :
                                $class_status = ' loteamento';
                                $text_status = 'EM LOTEAMENTO';
                                break;
                            case 4 :
                                $class_status = ' encerrado';
                                $text_status = 'ENCERRADO';
                                break;
                        endswitch
                        ;
                        ?>

                        <div class="data-status <?php echo $class_status; ?>">
                            <div class="status-leilao">
                                <em class="label-status"><?php
                                    if ($row->TIPO != 'DI') {
                                        echo $text_status;
                                    } else {
                                        echo 'VENDA DIRETA';
                                    }
                                    ?></em>
                                <div class="clearfix"></div>
                            </div>
                            <span class="display-bt-status plus"><i class="fa fa-plus"></i></span>
                            <span class="display-bt-status minus"><i class="fa fa-circle"></i></span>
                            <span class="display-bt-status ban"><i class="fa fa-minus"></i></span>
                            <span class="display-bt-status time"><i class="fa fa-clock-o"></i></span>
                            <span class="status-label-info"><?php echo $text_status; ?></span>

                        </div>
                    </a></li>
                <?php
            endforeach
            ;

        endif;
        ?>
    </ul>

</div>



<div class="categories-reponsive">
    <div class="container-itens-responsive">
        <a href="#andamento" class="leilao tpanel green">Em Andamento  <i class="fa fa-angle-right"></i></a>
        <a href="#maxpanel" class="leilao  blue tpanel">Maxlive  <i class="fa fa-angle-right"></i></a>
        <a href="#categories" class="leilao  red tpanel">Categorias  <i class="fa fa-angle-right"></i></a>
        <a href="#closeds" class="leilao  orange tpanel ">Últimos Realizados  <i class="fa fa-angle-right"></i></a>
    </div>   
    <div class="panel-leiloes" data-id-painel="andamento">
        <a href="#" class="leilao green p-close"><i class="fa fa-angle-left"> </i>Em Andamento</a>
        <ul>
            <?php echo $leilao_opened; ?>
        </ul>
    </div>

    <div class="panel-leiloes" data-id-painel="maxpanel">
        <a href="#" class="leilao blue p-close"><i class="fa fa-angle-left"> </i>Maxlive</a>
        <ul>
            <?php echo $leilao_maxlive; ?>
        </ul>
    </div>

    <div class="panel-leiloes" data-id-painel="closeds">
        <a href="#" class="leilao orange p-close"><i class="fa fa-angle-left"> </i> Últimos Realizados</a>
        <ul>
            <?php echo $leilao_closed; ?>
        </ul>
    </div>

    <div class="panel-leiloes" data-id-painel="categories">
        <a href="#" class="leilao red p-close"><i class="fa fa-angle-left"> </i>Categorias</a>
        <ul>
            <?php echo $this->load->get_var('menuMobile'); ?>
        </ul>
    </div>
</div>
<?php if (userData()->id == 0): ?>
    <a href="<?php echo site_url(BASE_URL_USER . '/login' . (uri_string() != '' ? '?r=' . uri_string() : '')); ?>" class="link-login login-responsive">
        Login ou cadastra-se
    </a>
<?php endif; ?>

<?php if (userData()->id > 0): ?>
    <a href="<?php echo site_url(BASE_URL_USER . '/painel') ?>" class="link-login login-responsive">
        Minha Conta
    </a>
<?php endif; ?>

